package com.asiainfo.hybridapp.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;

import com.asiainfo.hybridapp.R;
import com.asiainfo.hybridapp.activity.BaseActivity;
import com.asiainfo.hybridapp.activity.MeetingListActivity;
import com.asiainfo.hybridapp.entity.MeetingRankInfo;
import com.framework2.baseEvent.BaseOnClickListener;
import com.library.adapter_recyclerview.UniversalAdapter;

import java.util.List;

/**
 * 人口排行adapter
 *
 * @author YobertJomi
 * className PopulationRankAdapter
 * created at  2017/6/16  10:49
 */
public class MeetingRankAdapter extends UniversalAdapter<MeetingRankInfo> {
    private Context context;

    public MeetingRankAdapter(@NonNull Context context, @LayoutRes int layoutId, @Nullable List list) {
        super(context, layoutId, list);
        this.context = context;
    }

    @Override
    protected void getItemView(UniversalViewHolder viewHolder, final MeetingRankInfo item, int position) {
        viewHolder.setText(R.id.tvTitle, TextUtils.isEmpty(item.getTitle()) ? "title" : item.getTitle());
        viewHolder.setText(R.id.tvDate, TextUtils.isEmpty(item.getDate()) ? "date" : item.getDate());
        viewHolder.setText(R.id.tvCount, item.getCount1() + "人");
        viewHolder.itemView.setOnClickListener(new BaseOnClickListener() {
            @Override
            protected void onBaseClick(View v) {
                ((BaseActivity) context).startActivity(MeetingListActivity.class, item);
            }
        });
    }
}
